package com.example.aicooking.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DifyMessageRequest {
    private String query;
    private String conversation_id;
    private String response_mode = "streaming";
    private String user;
    private Map<String, String> inputs = new HashMap<>();
    private List<FileInfo> files;  // 添加files字段

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class FileInfo {
        private String type;
        private String transfer_method;
        private String upload_file_id;
    }

    // 普通聊天的构造函数
    public DifyMessageRequest(String query, String conversation_id, String userId) {
        this.query = query;
        this.conversation_id = conversation_id;
        this.user = userId;
        this.inputs = new HashMap<>();
        this.inputs.put("query", query);
    }

    // 带图片的聊天构造函数
    public DifyMessageRequest(String query, String conversation_id, String userId, String uploadFileId) {
        this(query, conversation_id, userId);  // 调用上面的构造函数

        // 添加图片信息
        FileInfo fileInfo = FileInfo.builder()
                .type("image")
                .transfer_method("local_file")
                .upload_file_id(uploadFileId)
                .build();

        this.files = new ArrayList<>();
        this.files.add(fileInfo);
    }
}
